#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cmath>
using namespace std;
using pii = pair<int, int>;
#define x first
#define y second
const int N = 155, INF = 0x3f3f3f3f;
pii q[N];
char g[N][N];
double dist[N][N], maxd[N];
int n;
double get_dist(pii a, pii b)
{
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> q[i].x >> q[i].y;
    for (int i = 0; i < n; i++) cin >> g[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i != j)
            {
                if (g[i][j] == '1') dist[i][j] = get_dist(q[i], q[j]);
                else dist[i][j] = INF;
            }
        }
    }
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (dist[i][j] < INF) maxd[i] = max(maxd[i], dist[i][j]);
        }
    }
    double res1 = 0;
    for (int i = 0; i < n; i++) res1 = max(res1, maxd[i]);
    double res2 = INF;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (dist[i][j] >= INF)
            {
                res2 = min(res2, get_dist(q[i], q[j]) + maxd[i] + maxd[j]);
            }
        }
    }
    printf("%lf\n", max(res1, res2));
    return 0;
}